-
Notifications
You must be signed in to change notification settings - Fork 0
[CLEAN] Synthetic Benchmark PR #36132 - FIX: silent failure when watched words contains invalid regex #7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: base_pr_36132_20251204_3908
Are you sure you want to change the base?
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
User description
Benchmark PR discourse#36132
Type: Clean (correct implementation)
Original PR Title: FIX: silent failure when watched words contains invalid regex
Original PR Description: If a watched words list contains any invalid regex, the test modal won't work because the "compiled" regex (that contains all the watched words) will be invalid.
This PR introduces a fallback to matching individual watched words when the compiled regex is invalid as well as displaying the error for each invalid regex.
Screen.Recording.2025-11-20.at.10.34.05.mov
Internal ref - t/168206
Original PR URL: discourse#36132
PR Type
Bug fix, Enhancement, Tests
Description
Handle invalid regex in watched words gracefully with fallback matching
Improve error display in admin UI for multiple invalid regexes
Add comprehensive test coverage for mixed valid/invalid regex scenarios
Diagram Walkthrough
flowchart LR A["Invalid Regex in Watched Words"] --> B["Log Warning + Return nil"] B --> C["Filter Out Invalid Regexes"] C --> D["Compile Valid Regexes"] D --> E{"Compiled Regex Valid?"} E -->|Yes| F["Use Compiled Regex"] E -->|No| G["Fall Back to Individual Words"] F --> H["Display Matches"] G --> H I["Admin UI"] --> J["Show All Regex Errors"] J --> K["List with Error Details"]File Walkthrough
word_watcher.rb
Add error handling and logging for invalid regexesapp/services/word_watcher.rb
compilation failures
nilfor invalid regexes instead of raising exceptionsword_watcher_spec.rb
Add tests for invalid regex compilation handlingspec/services/word_watcher_spec.rb
serialized_regexps_for_actionworks with mixedvalid/invalid regexes
admin-watched-words-test.js
Add acceptance tests for invalid regex handlingfrontend/discourse/tests/acceptance/admin-watched-words-test.js
regex
patterns
action.js
Refactor to collect and display multiple regex errorsfrontend/discourse/admin/controllers/admin-watched-words/action.js
regexpErrorgetter toregexpErrorsreturning array of errors@cacheddecorator for performance optimizationwatched-word-testing.gjs
Add error handling and fallback matching in test modalfrontend/discourse/admin/components/modal/watched-word-testing.gjs
matchesgetter tomatchesAndErrorsreturning both matchesand errors
expression fails
cleanErrorMessagehelper to extract error detailsaction.gjs
Update template to display multiple regex errorsfrontend/discourse/admin/templates/admin-watched-words/action.gjs
regexpErrorsarray.watched-word-regex-errorsstyling classstaff_logs.scss
Add styling for regex error list displayapp/assets/stylesheets/admin/staff_logs.scss
.watched-word-regex-errorsclass for styling error listclient.en.yml
Add translation for multiple regex errorsconfig/locales/client.en.yml
invalid_regex_multiplefor multiple errorsheader
invalid_regexkey for backward compatibility